<!DOCTYPE html>
<html lang="">
<head>
    <meta charset="utf-8">
    <title>Retina Dashboard</title>
    <meta name="description" content="" />
    <meta name="keywords" content="" />
    <meta name="robots" content="" />
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" href="/static/css/style.css" media="all" />

    <script src="http://cdn.bootcss.com/jquery/2.1.1/jquery.min.js"></script>
    <script src="/static/js/jquery.wysiwyg.js"></script>
    <script src="/static/js/jquery.checkbox.min.js"></script>

    <script src="/static/js/jquery.tablesorter.min.js"></script>
    <!--<script src="http://Code.highcharts.com/highcharts.js"></script>-->
    <!--<script src="jquery-1.11.2.js"></script>-->

    <style type="text/css">


    </style>
</head>
<body>
<div class="testing">
    <header class="main">
        <h1><strong>Retina</strong> Dashboard</h1>
        <!--<input type="text" value="search" />-->
    </header>
    <section class="user">
        <div class="profile-img">
            <img src="/static/images/uiface2.png" alt="" height="40" width="40" /> Welcome back John Doe
        </div>
        <div class="buttons">
            <span class="button blue"><a href="/admin/login_out/{{.tel}}">登出</a></span>
        </div>
    </section>
</div>
<nav>
    <ul>
        <li ><a href="/admin/index/{{.tel}}"><span class="icon">&#128711;</span> 设备监控</a></li>
        <li><a href=/admin/admin_list/{{.tel}}><span class="icon">&#128101;</span> 管理员 </a></li>
        <li>
            <a href="/admin/sys_setting/{{.tel}}"><span class="icon">&#9881;</span>系统设置</a>
        </li>
        <li>
            <a href="/admin/show_remote_list/{{.tel}}"><span class="icon">&#9881;</span>显示遥控数据</a>
        </li>
        <li class="section">
            <a href="/admin/add_remote_data/{{.tel}}"><span class="icon">&#9881;</span>添加遥控数据</a>
        </li>
    </ul>
</nav>

<section class="topcontent">
<section class="widget">
<header>
    <span class="icon">&#128200;</span>
    <hgroup>
        <h1>基本信息</h1>
    </hgroup>
    <aside>
        <button id="submit_btn" type="button">提交</button>
    </aside>
</header>
<section class="widget1">
<!--<div class="div_left">
</div>-->
<div class="user_form_class">
<br>
<div id="ziti1"><center> 用户空调数据</center></div>
<br>
<table border="1">
    <tr>
        <td>
            <center>
                <div class="input_tag">遥控器的名字</div>
            </center>
        </td>
        <td><input type="text" class=text id="RemoteName"></td>
        <td><pre></pre></td>
        <td>
            <center>
                <div class="input_tag">编号</div>
            </center>
        </td>
        <td><input type="text" class=text id="No"></td>
    </tr>
    <tr>
        <td>
            <center>
                <div class="input_tag">版本号</div>
            </center>
        </td>
        <td>
            <input type="text" class=text id="Version">
        </td>
        <td><pre>                                        </pre></td>
        <td>
            <center><div class="input_tag">设备型号</div></center>
        </td>
        <td>
            <input type="text" class=text id="DeviceType">
        </td>
    </tr>
    <!--<tr>-->
    <!--<td>-->
    <!--<center>-->
    <!--<div class="input_tag">无效位</div>-->
    <!--</center>-->
    <!--</td>-->
    <!--<td>-->
    <!--<input type="text" class=text id="SaveUrl">-->
    <!--</td>-->
    <!--<td></td>-->
    <!--<td><center><div class="input_tag">上传的用户ID</div></center></td>-->
    <!--<td><input type="text" class=text id="User"></td>-->
    <!--</tr>-->
    <tr>
        <td>
            <center><div class="input_tag">载波频率</div></center>
        </td>
        <td>
            <input type="text" class=text id="IRFRQ">
        </td>
        <td></td>
        <td>
            <center><div class="input_tag">采样脉冲宽度</div></center>
        </td>
        <td><input type="text" class=text id="TimeScale"></td>
    </tr>
    <tr>
        <td>
            <center>
                <div class="input_tag">关机码字</div>
            </center>
        </td>
        <td><input type="text" class=text id="PoweroffCode"></td>
</tr>
<tr>
        <td><center><div class="input_tag">开机码字</div></center></td>
        <td><input type="text" class=text id="BootCode"></td>
    </tr>

    <tr>
        <td>
        </td>
        <td>
            <!--<button id="acCode_btn" type="button" style="height:38px;width:140px;">AcCode格式</button>-->
        </td>
        <td></td>
        <td></td>
        <!--<td>
            <!--<button id="commonCode_btn" type="button" style="height:38px;width:140px;">CommonCode格式</button>
        </td>
    <!--<td><input type="radio" name="radiobutton" id="radio1" value=1  groupname="radio12"><div id="ziti2">AcCode格式</div></td><td></td><td><input type="radio" name="radiobutton" id="radio2" value=2  groupname="radio12">CommonCode格式</td>-->
    </tr>
</table>
<!--</div>
<div class="accode_form_class">-->
<div id="ziti2">Accode格式</div>
<br>
<div id="temperature_array"><p>温度数据</p>
    <button id="add_tempture_btn">添加框</button>
</div>
<br>
<table border="1">
    <tr>
        <td><center><div id="model">模式</div></center></td><td><center><div class="form_tag">开始的位数</div></center></td><td><center><div class="form_tag">码值</div></center></td><td><center><div class="form_tag">位宽</div></center></td>
    </tr>
    <tr>
        <td>
            <center>
                <div id="WindAutoModel_TAG">风速自动模式</div>
            </center>
        </td>
        <div class="WindAutoModel">
            <td><center><input type="text"  class="WindAutoModel StartAddr"/></center></td>
            <td><center><input type="text"  class="WindAutoModel Code"/></center></td>
            <td><center><input type="text"  class="WindAutoModel BitLength"></center></td>
        </div>
    </tr>
    <tr>
        <td>
            <center>
                <div id="WindHighModel_TAG">风速高模式</div>
            </center>
        </td>
        <div class="WindHighModel">
            <td><center><input type="text" class="WindHighModel StartAddr"></center></td>
            <td><center><input type="text" class="WindHighModel Code"></center></td>
            <td><center><input type="text" class="WindHighModel BitLength"></center></td>
        </div>
    </tr>
    <tr>
        <td>
            <center>
                <div id="WindMidModel_TAG">风速中模式</div>
            </center>
        </td>
        <div class="WindMidModel">
            <td><center><input type="text" class="WindMidModel StartAddr"></center></td>
            <td><center><input type="text"  class="WindMidModel Code"></center></td>
            <td><center><input type="text"  class="WindMidModel BitLength"></center></td>
        </div>
    </tr>
    <tr>
        <td>
            <center>
                <div id="WindLowModel_TAG">风速低模式</div>
            </center>
        </td>
        <div class="WindLowModel">
            <td><center><input type="text" class="WindLowModel StartAddr"></center></td>
            <td><center><input type="text" class="WindLowModel Code"></center></td>
            <td><center><input type="text" class="WindLowModel BitLength"></center></td>
        </div>
    </tr>
    <tr>
        <td>
            <center>
                <div id="HotModel_TAG">制热模式</div>
            </center>
        </td>
        <div class="HotModel">
            <td><center><input type="text" class="HotModel StartAddr"></center></td>
            <td><center><input type="text" class="HotModel Code"></center></td>
            <td><center><input type="text" class="HotModel BitLength"></center></td>
        </div>
    <tr>
        <td>
            <center>
                <div id="CodeModel_TAG">制冷模式</div>
            </center>
        </td>
        <div class="CodeModel">
            <td><center><input type="text" class="CodeModel StartAddr"></center></td>
            <td><center><input type="text" class="CodeModel Code"></center></td>
            <td><center><input type="text" class="CodeModel BitLength"></center></td>
        </div>
    </tr>
    <tr>
        <td>
            <center>
                <div id="VentilateModel_TAG">通风模式</div>
            </center>
        </td>
        <div class="VentilateModel">
            <td><center><input type="text" class="VentilateModel StartAddr"></center></td>
            <td><center><input type="text" class="VentilateModel Code"></center></td>
            <td><center><input type="text" class="VentilateModel BitLength"></center></td>
        </div>
    </tr>
    <tr>
        <td>
            <center>
                <div id="DehumidifyModel_TAG">除湿模式</div>
            </center>
        </td>
        <div class="DehumidifyModel">
            <td><center><input type="text" class="DehumidifyModel StartAddr"></center></td>
            <td><center><input type="text" class="DehumidifyModel Code"></center></td>
            <td><center><input type="text" class="DehumidifyModel BitLength"></center></td>
        </div>
    </tr>

    <tr>
        <td>
            <center>
                <div id="DefaultCode_TAG">编码模板</div>
            </center>
        </td>
        <td><center><input type="text" class=text id="DefaultCode"></center></td>
    </tr>
</table>
</div>
<!--	<div class="div_right">
	</div>
<!--<div class="CommonCode_form_class">
<div id="CommonCode" style="display:none;width:50%;margin-left:240px">
<br>
<br>
<ol>
</ol>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button id="add_commoncode_btn" type="button">添加框</button>
<br>
</div>
<br>
<br>
</div>
</div>-->
</section>
</section>
</section>
</body>

<script>

    $(document).ready(function(){
        var json_data = {
            "ObjectId": "54b2a63ee3606611c8000001",
            "RemoteName": "",
            "No": "",
            "Version": "",
            "DeviceType": 0,
            "Descript": "",
            "SaveUrl": "",
            "User": 1,
            "UpdateTime": "0001-01-01T00:00:00Z",
            "TimeScale": 0,
            "IRFRQ": 0,
            "BootCode": "0x010x020x03",
            "PoweroffCode": "",
            "AcCode":{
                "TemperatureData": [],
                "WindAutoModel": {
                    "StartAddr": 0,
                    "Code": 0,
                    "BitLength": 0
                },
                "WindHighModel": {
                    "StartAddr": 0,
                    "Code": 0,
                    "BitLength": 0
                },
                "WindMidModel": {
                    "StartAddr": 0,
                    "Code": 0,
                    "BitLength": 0
                },
                "WindLowModel": {
                    "StartAddr": 0,
                    "Code": 0,
                    "BitLength": 0
                },
                "HotModel": {
                    "StartAddr": 0,
                    "Code": 0,
                    "BitLength": 0
                },
                "CodeModel": {
                    "StartAddr": 0,
                    "Code": 0,
                    "BitLength": 0
                },
                "VentilateModel": {
                    "StartAddr": 0,
                    "Code": 0,
                    "BitLength": 0
                },
                "DehumidifyModel": {
                    "StartAddr": 0,
                    "Code": 0,
                    "BitLength": 0
                },
                "DefaultCode": ""
            },
            "CommonCode":[{"key":"test","Value":"test"}]

        }

        console.log(json_data);
        commoncpoe_id=0;
        accode_id=0;
        $("#add_tempture_btn").click(function(){
            $("p").append('<input type="text" id="id_"+accode_id'+ "class=text>");
            accode_id++;
        });

        //$("#add_commoncode_btn").click(function(){
        //$("ol").append("<li>key<input type=text id='key_'+commoncpoe_id+'' class=text>&nbsp;&nbsp;&nbsp;&nbsp;value<input type=text id='value_'+commoncpoe_id+'' class=text></li>");commoncpoe_id++;
        //});

//$("#acCode_btn").click(function(){
        //$("#acCode").show();
        //$("#CommonCode").hide();
        //});
//        <!--$("#commonCode_btn").click(function(){
//            <!--$("#CommonCode").show();
//            <!--$("#acCode").hide();
//            <!--});


        $("#submit_btn").click(function(){
            console.log($(".WindAutoModel.StartAddr").val());
            json_data.RemoteName=$("#RemoteName").val();
            json_data.No=$("#No").val();
            json_data.Version=$("#Version").val();
            json_data.DeviceType=parseInt($("#DeviceType").val());
            //json_data.SaveUrl=$("#SaveUrl").val();
            //json_data.User=parseInt($("#User").val());
            //json_data.UpdateTime=$("#UpdateTime").val();
            json_data.TimeScale=parseInt($("#TimeScale").val());
            json_data.IRFRQ=parseInt($("#IRFRQ").val());
            json_data.BootCode=$("#BootCode").val();
            json_data.PoweroffCode=$("#PoweroffCode").val();
            json_data.AcCode.WindAutoModel.StartAddr=parseInt($(".WindAutoModel.StartAddr").val());
            json_data.AcCode.WindAutoModel.Code=$(".WindAutoModel.Code").val();
            json_data.AcCode.WindAutoModel.BitLength=parseInt($(".WindAutoModel.BitLength").val());
            json_data.AcCode.WindHighModel.StartAddr=parseInt($(".WindHighModel.StartAddr").val());
            json_data.AcCode.WindHighModel.Code=$(".WindHighModel.Code").val();
            json_data.AcCode.WindHighModel.BitLength=parseInt($(".WindHighModel.BitLength").val());
            json_data.AcCode.WindMidModel.StartAddr=parseInt($(".WindMidModel.StartAddr").val());
            json_data.AcCode.WindMidModel.Code=$(".WindMidModel.Code").val();
            json_data.AcCode.WindMidModel.BitLength=parseInt($(".WindMidModel.BitLength").val());
            json_data.AcCode.WindLowModel.StartAddr=parseInt($(".WindLowModel.StartAddr").val());
            json_data.AcCode.WindLowModel.Code=$(".WindLowModel.Code").val();
            json_data.AcCode.WindLowModel.BitLength=parseInt($(".WindLowModel.BitLength").val());
            json_data.AcCode.HotModel.StartAddr=parseInt($(".HotModel.StartAddr").val());
            json_data.AcCode.HotModel.Code=$(".HotModel.Code").val();
            json_data.AcCode.HotModel.BitLength=parseInt($(".HotModel.BitLength").val());
            json_data.AcCode.CodeModel.StartAddr=parseInt($(".CodeModel.StartAddr").val());
            json_data.AcCode.CodeModel.Code=$(".CodeModel.Code").val();
            json_data.AcCode.CodeModel.BitLength=parseInt($(".CodeModel.BitLength").val());
            json_data.AcCode.VentilateModel.StartAddr=parseInt($(".VentilateModel.StartAddr").val());
            json_data.AcCode.VentilateModel.Code=$(".VentilateModel.Code").val();
            json_data.AcCode.VentilateModel.BitLength=parseInt($(".VentilateModel.BitLength").val());
            json_data.AcCode.DehumidifyModel.StartAddr=parseInt($(".DehumidifyModel.StartAddr").val());
            json_data.AcCode.DehumidifyModel.Code=$(".DehumidifyModel.Code").val();
            json_data.AcCode.DehumidifyModel.BitLength=parseInt($(".DehumidifyModel.BitLength").val());
            json_data.AcCode.DefaultCode=$("#DefaultCode").val();
            var aa= $("input[id^='id_']");
            console.log(json_data);
            for(var i=0;i<aa.length;i++)
            {
                json_data.AcCode.TemperatureData.push(aa[i].value);
            }
            var bb= $("input[id^='id_']");
            console.log(json_data.CommonCode);
            for(var i=0;i<bb.length;i++)
            {
                json_data.CommonCode.push(bb[i].value);
            }
            $.ajax({
                type:"POST",
                url:"http://localhost:8080/admin/api/add_remote_data/{{.tel}}",
                data:JSON.stringify(json_data),
                datatype:"json",
                success:function(data){
                    if(data.RespCode == 200){
                        alert(data.Msg);
                    }else{
                        alert(data.Msg);
                    }
                }
            });
        });


    });
</script>
</html>